#########################################################################################
## Replication Code for "Redistricting and the Causal Impact of Race on Voter Turnout" ##
## by Bernard L. Fraga ##
## as published in the Journal of Politics ##
#############################################

######################################################################################################
## Replication Code File 1 - Tables 1-3, with add'l data found in Tables B.1-B.3 of Online Appendix ##
## Tested with R v3.2.0, Platform: x86_64-apple-darwin13.4.0 (64-bit) ##
## Last Updated: Aug 11, 2015 ##
################################

###################################################################
## Load "DistrictStats.csv," New+Old District "Pair" level dataset ##
## NOTE: Multiple comparisons are made for same New-Old Pair, hence repeated rows ##

fraga1 <- read.csv("Fraga2016_DistrictStats.csv", stringsAsFactors=FALSE)
dim(fraga1) # Should be 2458 Rows by 25 Columns

###################################
## TABLE 1 (and B.1 of Appendix) ##

# Subset to Incumbent Treatment, split into Treatment and Control Districts
fraga1_Inc <- subset(fraga1, Treatment == "Inc")
fraga1_IncT <- subset(fraga1_Inc, PostDist == TreatDist)
fraga1_IncC <- subset(fraga1_Inc, PostDist == ControlDist)

# Stats for White Registrants
fraga1_IncT_W <- subset(fraga1_IncT, Group == "White")
fraga1_IncC_W <- subset(fraga1_IncC, Group == "White")

frame <- as.data.frame(c("N","District Pairs", "Pct Female","Pct Age 20-29","Pct Age 55+","Pct Turnout 06","Pct Turnout 08","Pct Turnout 10","Pct Turnout 12"))
colnames(frame) <- "X"

frame$Treated <- 0
frame$Treated[1] <- sum(fraga1_IncT_W[!duplicated(fraga1_IncT_W[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Treated[2] <- nrow(unique(subset(fraga1_IncT_W, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Treated[3] <- mean(fraga1_IncT_W$PctFem_U)
frame$Treated[4] <- mean(fraga1_IncT_W$Pct20_U)
frame$Treated[5] <- mean(fraga1_IncT_W$Pct55_U)
frame$Treated[6] <- mean(fraga1_IncT_W$Turnout06_U)
frame$Treated[7] <- mean(fraga1_IncT_W$Turnout08_U)
frame$Treated[8] <- mean(fraga1_IncT_W$Turnout10_U)
frame$Treated[9] <- mean(fraga1_IncT_W$Turnout12_U)

frame$Control <- 0
frame$Control[1] <- sum(fraga1_IncC_W[!duplicated(fraga1_IncC_W[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Control[2] <- nrow(unique(subset(fraga1_IncC_W, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Control[3] <- mean(fraga1_IncC_W$PctFem_U)
frame$Control[4] <- mean(fraga1_IncC_W$Pct20_U)
frame$Control[5] <- mean(fraga1_IncC_W$Pct55_U)
frame$Control[6] <- mean(fraga1_IncC_W$Turnout06_U)
frame$Control[7] <- mean(fraga1_IncC_W$Turnout08_U)
frame$Control[8] <- mean(fraga1_IncC_W$Turnout10_U)
frame$Control[9] <- mean(fraga1_IncC_W$Turnout12_U)

frame$PVal <- NA
frame$PVal[3] <- t.test(fraga1_IncT_W$PctFem_U, fraga1_IncC_W$PctFem_U)$p.value
frame$PVal[4] <- t.test(fraga1_IncT_W$Pct20_U, fraga1_IncC_W$Pct20_U)$p.value
frame$PVal[5] <- t.test(fraga1_IncT_W$Pct55_U, fraga1_IncC_W$Pct55_U)$p.value
frame$PVal[6] <- t.test(fraga1_IncT_W$Turnout06_U, fraga1_IncC_W$Turnout06_U)$p.value
frame$PVal[7] <- t.test(fraga1_IncT_W$Turnout08_U, fraga1_IncC_W$Turnout08_U)$p.value
frame$PVal[8] <- t.test(fraga1_IncT_W$Turnout10_U, fraga1_IncC_W$Turnout10_U)$p.value
frame$PVal[9] <- t.test(fraga1_IncT_W$Turnout12_U, fraga1_IncC_W$Turnout12_U)$p.value

frame$TreatedM <- 0
frame$TreatedM[1] <- sum(fraga1_IncT_W[!duplicated(fraga1_IncT_W[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$TreatedM[2] <- nrow(unique(subset(fraga1_IncT_W, select=c(State, PreDist, TreatDist, ControlDist))))
frame$TreatedM[3] <- mean(fraga1_IncT_W$PctFem_M)
frame$TreatedM[4] <- mean(fraga1_IncT_W$Pct20_M)
frame$TreatedM[5] <- mean(fraga1_IncT_W$Pct55_M)
frame$TreatedM[6] <- mean(fraga1_IncT_W$Turnout06_M)
frame$TreatedM[7] <- mean(fraga1_IncT_W$Turnout08_M)
frame$TreatedM[8] <- mean(fraga1_IncT_W$Turnout10_M)
frame$TreatedM[9] <- mean(fraga1_IncT_W$Turnout12_M)

frame$ControlM <- 0
frame$ControlM[1] <- sum(fraga1_IncC_W[!duplicated(fraga1_IncC_W[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$ControlM[2] <- nrow(unique(subset(fraga1_IncC_W, select=c(State, PreDist, TreatDist, ControlDist))))
frame$ControlM[3] <- mean(fraga1_IncC_W$PctFem_M)
frame$ControlM[4] <- mean(fraga1_IncC_W$Pct20_M)
frame$ControlM[5] <- mean(fraga1_IncC_W$Pct55_M)
frame$ControlM[6] <- mean(fraga1_IncC_W$Turnout06_M)
frame$ControlM[7] <- mean(fraga1_IncC_W$Turnout08_M)
frame$ControlM[8] <- mean(fraga1_IncC_W$Turnout10_M)
frame$ControlM[9] <- mean(fraga1_IncC_W$Turnout12_M)

frame$PValM <- NA
frame$PValM[3] <- t.test(fraga1_IncT_W$PctFem_M, fraga1_IncC_W$PctFem_M)$p.value
frame$PValM[4] <- t.test(fraga1_IncT_W$Pct20_M, fraga1_IncC_W$Pct20_M)$p.value
frame$PValM[5] <- t.test(fraga1_IncT_W$Pct55_M, fraga1_IncC_W$Pct55_M)$p.value
frame$PValM[6] <- t.test(fraga1_IncT_W$Turnout06_M, fraga1_IncC_W$Turnout06_M)$p.value
frame$PValM[7] <- t.test(fraga1_IncT_W$Turnout08_M, fraga1_IncC_W$Turnout08_M)$p.value
frame$PValM[8] <- t.test(fraga1_IncT_W$Turnout10_M, fraga1_IncC_W$Turnout10_M)$p.value
frame$PValM[9] <- t.test(fraga1_IncT_W$Turnout12_M, fraga1_IncC_W$Turnout12_M)$p.value

#######
frame # Matches statistics for Whites in Table 1 of Main Text and Table B.1 of Online Appendix
#######

# Stats for Black Registrants
fraga1_IncT_B <- subset(fraga1_IncT, Group == "Black")
fraga1_IncC_B <- subset(fraga1_IncC, Group == "Black")

frame <- as.data.frame(c("N","District Pairs", "Pct Female","Pct Age 20-29","Pct Age 55+","Pct Turnout 06","Pct Turnout 08","Pct Turnout 10","Pct Turnout 12"))
colnames(frame) <- "X"

frame$Treated <- 0
frame$Treated[1] <- sum(fraga1_IncT_B[!duplicated(fraga1_IncT_B[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Treated[2] <- nrow(unique(subset(fraga1_IncT_B, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Treated[3] <- mean(fraga1_IncT_B$PctFem_U)
frame$Treated[4] <- mean(fraga1_IncT_B$Pct20_U)
frame$Treated[5] <- mean(fraga1_IncT_B$Pct55_U)
frame$Treated[6] <- mean(fraga1_IncT_B$Turnout06_U)
frame$Treated[7] <- mean(fraga1_IncT_B$Turnout08_U)
frame$Treated[8] <- mean(fraga1_IncT_B$Turnout10_U)
frame$Treated[9] <- mean(fraga1_IncT_B$Turnout12_U)

frame$Control <- 0
frame$Control[1] <- sum(fraga1_IncC_B[!duplicated(fraga1_IncC_B[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Control[2] <- nrow(unique(subset(fraga1_IncC_B, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Control[3] <- mean(fraga1_IncC_B$PctFem_U)
frame$Control[4] <- mean(fraga1_IncC_B$Pct20_U)
frame$Control[5] <- mean(fraga1_IncC_B$Pct55_U)
frame$Control[6] <- mean(fraga1_IncC_B$Turnout06_U)
frame$Control[7] <- mean(fraga1_IncC_B$Turnout08_U)
frame$Control[8] <- mean(fraga1_IncC_B$Turnout10_U)
frame$Control[9] <- mean(fraga1_IncC_B$Turnout12_U)

frame$PVal <- NA
frame$PVal[3] <- t.test(fraga1_IncT_B$PctFem_U, fraga1_IncC_B$PctFem_U)$p.value
frame$PVal[4] <- t.test(fraga1_IncT_B$Pct20_U, fraga1_IncC_B$Pct20_U)$p.value
frame$PVal[5] <- t.test(fraga1_IncT_B$Pct55_U, fraga1_IncC_B$Pct55_U)$p.value
frame$PVal[6] <- t.test(fraga1_IncT_B$Turnout06_U, fraga1_IncC_B$Turnout06_U)$p.value
frame$PVal[7] <- t.test(fraga1_IncT_B$Turnout08_U, fraga1_IncC_B$Turnout08_U)$p.value
frame$PVal[8] <- t.test(fraga1_IncT_B$Turnout10_U, fraga1_IncC_B$Turnout10_U)$p.value
frame$PVal[9] <- t.test(fraga1_IncT_B$Turnout12_U, fraga1_IncC_B$Turnout12_U)$p.value

frame$TreatedM <- 0
frame$TreatedM[1] <- sum(fraga1_IncT_B[!duplicated(fraga1_IncT_B[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$TreatedM[2] <- nrow(unique(subset(fraga1_IncT_B, select=c(State, PreDist, TreatDist, ControlDist))))
frame$TreatedM[3] <- mean(fraga1_IncT_B$PctFem_M)
frame$TreatedM[4] <- mean(fraga1_IncT_B$Pct20_M)
frame$TreatedM[5] <- mean(fraga1_IncT_B$Pct55_M)
frame$TreatedM[6] <- mean(fraga1_IncT_B$Turnout06_M)
frame$TreatedM[7] <- mean(fraga1_IncT_B$Turnout08_M)
frame$TreatedM[8] <- mean(fraga1_IncT_B$Turnout10_M)
frame$TreatedM[9] <- mean(fraga1_IncT_B$Turnout12_M)

frame$ControlM <- 0
frame$ControlM[1] <- sum(fraga1_IncC_B[!duplicated(fraga1_IncC_B[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$ControlM[2] <- nrow(unique(subset(fraga1_IncC_B, select=c(State, PreDist, TreatDist, ControlDist))))
frame$ControlM[3] <- mean(fraga1_IncC_B$PctFem_M)
frame$ControlM[4] <- mean(fraga1_IncC_B$Pct20_M)
frame$ControlM[5] <- mean(fraga1_IncC_B$Pct55_M)
frame$ControlM[6] <- mean(fraga1_IncC_B$Turnout06_M)
frame$ControlM[7] <- mean(fraga1_IncC_B$Turnout08_M)
frame$ControlM[8] <- mean(fraga1_IncC_B$Turnout10_M)
frame$ControlM[9] <- mean(fraga1_IncC_B$Turnout12_M)

frame$PValM <- NA
frame$PValM[3] <- t.test(fraga1_IncT_B$PctFem_M, fraga1_IncC_B$PctFem_M)$p.value
frame$PValM[4] <- t.test(fraga1_IncT_B$Pct20_M, fraga1_IncC_B$Pct20_M)$p.value
frame$PValM[5] <- t.test(fraga1_IncT_B$Pct55_M, fraga1_IncC_B$Pct55_M)$p.value
frame$PValM[6] <- t.test(fraga1_IncT_B$Turnout06_M, fraga1_IncC_B$Turnout06_M)$p.value
frame$PValM[7] <- t.test(fraga1_IncT_B$Turnout08_M, fraga1_IncC_B$Turnout08_M)$p.value
frame$PValM[8] <- t.test(fraga1_IncT_B$Turnout10_M, fraga1_IncC_B$Turnout10_M)$p.value
frame$PValM[9] <- t.test(fraga1_IncT_B$Turnout12_M, fraga1_IncC_B$Turnout12_M)$p.value

#######
frame # Matches statistics for Blacks in Table 1 of Main Text and Table B.1 of Online Appendix
#######

# Stats for Latino Registrants
fraga1_IncT_L <- subset(fraga1_IncT, Group == "Latino")
fraga1_IncC_L <- subset(fraga1_IncC, Group == "Latino")

frame <- as.data.frame(c("N","District Pairs", "Pct Female","Pct Age 20-29","Pct Age 55+","Pct Turnout 06","Pct Turnout 08","Pct Turnout 10","Pct Turnout 12"))
colnames(frame) <- "X"

frame$Treated <- 0
frame$Treated[1] <- sum(fraga1_IncT_L[!duplicated(fraga1_IncT_L[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Treated[2] <- nrow(unique(subset(fraga1_IncT_L, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Treated[3] <- mean(fraga1_IncT_L$PctFem_U)
frame$Treated[4] <- mean(fraga1_IncT_L$Pct20_U)
frame$Treated[5] <- mean(fraga1_IncT_L$Pct55_U)
frame$Treated[6] <- mean(fraga1_IncT_L$Turnout06_U)
frame$Treated[7] <- mean(fraga1_IncT_L$Turnout08_U)
frame$Treated[8] <- mean(fraga1_IncT_L$Turnout10_U)
frame$Treated[9] <- mean(fraga1_IncT_L$Turnout12_U)

frame$Control <- 0
frame$Control[1] <- sum(fraga1_IncC_L[!duplicated(fraga1_IncC_L[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Control[2] <- nrow(unique(subset(fraga1_IncC_L, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Control[3] <- mean(fraga1_IncC_L$PctFem_U)
frame$Control[4] <- mean(fraga1_IncC_L$Pct20_U)
frame$Control[5] <- mean(fraga1_IncC_L$Pct55_U)
frame$Control[6] <- mean(fraga1_IncC_L$Turnout06_U)
frame$Control[7] <- mean(fraga1_IncC_L$Turnout08_U)
frame$Control[8] <- mean(fraga1_IncC_L$Turnout10_U)
frame$Control[9] <- mean(fraga1_IncC_L$Turnout12_U)

frame$PVal <- NA
frame$PVal[3] <- t.test(fraga1_IncT_L$PctFem_U, fraga1_IncC_L$PctFem_U)$p.value
frame$PVal[4] <- t.test(fraga1_IncT_L$Pct20_U, fraga1_IncC_L$Pct20_U)$p.value
frame$PVal[5] <- t.test(fraga1_IncT_L$Pct55_U, fraga1_IncC_L$Pct55_U)$p.value
frame$PVal[6] <- t.test(fraga1_IncT_L$Turnout06_U, fraga1_IncC_L$Turnout06_U)$p.value
frame$PVal[7] <- t.test(fraga1_IncT_L$Turnout08_U, fraga1_IncC_L$Turnout08_U)$p.value
frame$PVal[8] <- t.test(fraga1_IncT_L$Turnout10_U, fraga1_IncC_L$Turnout10_U)$p.value
frame$PVal[9] <- t.test(fraga1_IncT_L$Turnout12_U, fraga1_IncC_L$Turnout12_U)$p.value

frame$TreatedM <- 0
frame$TreatedM[1] <- sum(fraga1_IncT_L[!duplicated(fraga1_IncT_L[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$TreatedM[2] <- nrow(unique(subset(fraga1_IncT_L, select=c(State, PreDist, TreatDist, ControlDist))))
frame$TreatedM[3] <- mean(fraga1_IncT_L$PctFem_M)
frame$TreatedM[4] <- mean(fraga1_IncT_L$Pct20_M)
frame$TreatedM[5] <- mean(fraga1_IncT_L$Pct55_M)
frame$TreatedM[6] <- mean(fraga1_IncT_L$Turnout06_M)
frame$TreatedM[7] <- mean(fraga1_IncT_L$Turnout08_M)
frame$TreatedM[8] <- mean(fraga1_IncT_L$Turnout10_M)
frame$TreatedM[9] <- mean(fraga1_IncT_L$Turnout12_M)

frame$ControlM <- 0
frame$ControlM[1] <- sum(fraga1_IncC_L[!duplicated(fraga1_IncC_L[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$ControlM[2] <- nrow(unique(subset(fraga1_IncC_L, select=c(State, PreDist, TreatDist, ControlDist))))
frame$ControlM[3] <- mean(fraga1_IncC_L$PctFem_M)
frame$ControlM[4] <- mean(fraga1_IncC_L$Pct20_M)
frame$ControlM[5] <- mean(fraga1_IncC_L$Pct55_M)
frame$ControlM[6] <- mean(fraga1_IncC_L$Turnout06_M)
frame$ControlM[7] <- mean(fraga1_IncC_L$Turnout08_M)
frame$ControlM[8] <- mean(fraga1_IncC_L$Turnout10_M)
frame$ControlM[9] <- mean(fraga1_IncC_L$Turnout12_M)

frame$PValM <- NA
frame$PValM[3] <- t.test(fraga1_IncT_L$PctFem_M, fraga1_IncC_L$PctFem_M)$p.value
frame$PValM[4] <- t.test(fraga1_IncT_L$Pct20_M, fraga1_IncC_L$Pct20_M)$p.value
frame$PValM[5] <- t.test(fraga1_IncT_L$Pct55_M, fraga1_IncC_L$Pct55_M)$p.value
frame$PValM[6] <- t.test(fraga1_IncT_L$Turnout06_M, fraga1_IncC_L$Turnout06_M)$p.value
frame$PValM[7] <- t.test(fraga1_IncT_L$Turnout08_M, fraga1_IncC_L$Turnout08_M)$p.value
frame$PValM[8] <- t.test(fraga1_IncT_L$Turnout10_M, fraga1_IncC_L$Turnout10_M)$p.value
frame$PValM[9] <- t.test(fraga1_IncT_L$Turnout12_M, fraga1_IncC_L$Turnout12_M)$p.value

#######
frame # Matches statistics for Latinos in Table 1 of Main Text and Table B.1 of Online Appendix
#######

# Stats for Asian Registrants
fraga1_IncT_A <- subset(fraga1_IncT, Group == "Asian")
fraga1_IncC_A <- subset(fraga1_IncC, Group == "Asian")

frame <- as.data.frame(c("N","District Pairs", "Pct Female","Pct Age 20-29","Pct Age 55+","Pct Turnout 06","Pct Turnout 08","Pct Turnout 10","Pct Turnout 12"))
colnames(frame) <- "X"

frame$Treated <- 0
frame$Treated[1] <- sum(fraga1_IncT_A[!duplicated(fraga1_IncT_A[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Treated[2] <- nrow(unique(subset(fraga1_IncT_A, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Treated[3] <- mean(fraga1_IncT_A$PctFem_U)
frame$Treated[4] <- mean(fraga1_IncT_A$Pct20_U)
frame$Treated[5] <- mean(fraga1_IncT_A$Pct55_U)
frame$Treated[6] <- mean(fraga1_IncT_A$Turnout06_U)
frame$Treated[7] <- mean(fraga1_IncT_A$Turnout08_U)
frame$Treated[8] <- mean(fraga1_IncT_A$Turnout10_U)
frame$Treated[9] <- mean(fraga1_IncT_A$Turnout12_U)

frame$Control <- 0
frame$Control[1] <- sum(fraga1_IncC_A[!duplicated(fraga1_IncC_A[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Control[2] <- nrow(unique(subset(fraga1_IncC_A, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Control[3] <- mean(fraga1_IncC_A$PctFem_U)
frame$Control[4] <- mean(fraga1_IncC_A$Pct20_U)
frame$Control[5] <- mean(fraga1_IncC_A$Pct55_U)
frame$Control[6] <- mean(fraga1_IncC_A$Turnout06_U)
frame$Control[7] <- mean(fraga1_IncC_A$Turnout08_U)
frame$Control[8] <- mean(fraga1_IncC_A$Turnout10_U)
frame$Control[9] <- mean(fraga1_IncC_A$Turnout12_U)

frame$PVal <- NA
frame$PVal[3] <- t.test(fraga1_IncT_A$PctFem_U, fraga1_IncC_A$PctFem_U)$p.value
frame$PVal[4] <- t.test(fraga1_IncT_A$Pct20_U, fraga1_IncC_A$Pct20_U)$p.value
frame$PVal[5] <- t.test(fraga1_IncT_A$Pct55_U, fraga1_IncC_A$Pct55_U)$p.value
frame$PVal[6] <- t.test(fraga1_IncT_A$Turnout06_U, fraga1_IncC_A$Turnout06_U)$p.value
frame$PVal[7] <- t.test(fraga1_IncT_A$Turnout08_U, fraga1_IncC_A$Turnout08_U)$p.value
frame$PVal[8] <- t.test(fraga1_IncT_A$Turnout10_U, fraga1_IncC_A$Turnout10_U)$p.value
frame$PVal[9] <- t.test(fraga1_IncT_A$Turnout12_U, fraga1_IncC_A$Turnout12_U)$p.value

frame$TreatedM <- 0
frame$TreatedM[1] <- sum(fraga1_IncT_A[!duplicated(fraga1_IncT_A[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$TreatedM[2] <- nrow(unique(subset(fraga1_IncT_A, select=c(State, PreDist, TreatDist, ControlDist))))
frame$TreatedM[3] <- mean(fraga1_IncT_A$PctFem_M)
frame$TreatedM[4] <- mean(fraga1_IncT_A$Pct20_M)
frame$TreatedM[5] <- mean(fraga1_IncT_A$Pct55_M)
frame$TreatedM[6] <- mean(fraga1_IncT_A$Turnout06_M)
frame$TreatedM[7] <- mean(fraga1_IncT_A$Turnout08_M)
frame$TreatedM[8] <- mean(fraga1_IncT_A$Turnout10_M)
frame$TreatedM[9] <- mean(fraga1_IncT_A$Turnout12_M)

frame$ControlM <- 0
frame$ControlM[1] <- sum(fraga1_IncC_A[!duplicated(fraga1_IncC_A[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$ControlM[2] <- nrow(unique(subset(fraga1_IncC_A, select=c(State, PreDist, TreatDist, ControlDist))))
frame$ControlM[3] <- mean(fraga1_IncC_A$PctFem_M)
frame$ControlM[4] <- mean(fraga1_IncC_A$Pct20_M)
frame$ControlM[5] <- mean(fraga1_IncC_A$Pct55_M)
frame$ControlM[6] <- mean(fraga1_IncC_A$Turnout06_M)
frame$ControlM[7] <- mean(fraga1_IncC_A$Turnout08_M)
frame$ControlM[8] <- mean(fraga1_IncC_A$Turnout10_M)
frame$ControlM[9] <- mean(fraga1_IncC_A$Turnout12_M)

frame$PValM <- NA
frame$PValM[3] <- t.test(fraga1_IncT_A$PctFem_M, fraga1_IncC_A$PctFem_M)$p.value
frame$PValM[4] <- t.test(fraga1_IncT_A$Pct20_M, fraga1_IncC_A$Pct20_M)$p.value
frame$PValM[5] <- t.test(fraga1_IncT_A$Pct55_M, fraga1_IncC_A$Pct55_M)$p.value
frame$PValM[6] <- t.test(fraga1_IncT_A$Turnout06_M, fraga1_IncC_A$Turnout06_M)$p.value
frame$PValM[7] <- t.test(fraga1_IncT_A$Turnout08_M, fraga1_IncC_A$Turnout08_M)$p.value
frame$PValM[8] <- t.test(fraga1_IncT_A$Turnout10_M, fraga1_IncC_A$Turnout10_M)$p.value
frame$PValM[9] <- t.test(fraga1_IncT_A$Turnout12_M, fraga1_IncC_A$Turnout12_M)$p.value

#######
frame # Matches statistics for Asians in Table 1 of Main Text and Table B.1 of Online Appendix
#######

###################################
## TABLE 2 (and B.2 of Appendix) ##

# Subset to Candidate Treatment, split into Treatment and Control Districts
fraga1_Cand <- subset(fraga1, Treatment == "Cand")
fraga1_CandT <- subset(fraga1_Cand, PostDist == TreatDist)
fraga1_CandC <- subset(fraga1_Cand, PostDist == ControlDist)

# Stats for White Registrants
fraga1_CandT_W <- subset(fraga1_CandT, Group == "White")
fraga1_CandC_W <- subset(fraga1_CandC, Group == "White")

frame <- as.data.frame(c("N","District Pairs", "Pct Female","Pct Age 20-29","Pct Age 55+","Pct Turnout 06","Pct Turnout 08","Pct Turnout 10","Pct Turnout 12"))
colnames(frame) <- "X"

frame$Treated <- 0
frame$Treated[1] <- sum(fraga1_CandT_W[!duplicated(fraga1_CandT_W[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Treated[2] <- nrow(unique(subset(fraga1_CandT_W, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Treated[3] <- mean(fraga1_CandT_W$PctFem_U)
frame$Treated[4] <- mean(fraga1_CandT_W$Pct20_U)
frame$Treated[5] <- mean(fraga1_CandT_W$Pct55_U)
frame$Treated[6] <- mean(fraga1_CandT_W$Turnout06_U)
frame$Treated[7] <- mean(fraga1_CandT_W$Turnout08_U)
frame$Treated[8] <- mean(fraga1_CandT_W$Turnout10_U)
frame$Treated[9] <- mean(fraga1_CandT_W$Turnout12_U)

frame$Control <- 0
frame$Control[1] <- sum(fraga1_CandC_W[!duplicated(fraga1_CandC_W[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Control[2] <- nrow(unique(subset(fraga1_CandC_W, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Control[3] <- mean(fraga1_CandC_W$PctFem_U)
frame$Control[4] <- mean(fraga1_CandC_W$Pct20_U)
frame$Control[5] <- mean(fraga1_CandC_W$Pct55_U)
frame$Control[6] <- mean(fraga1_CandC_W$Turnout06_U)
frame$Control[7] <- mean(fraga1_CandC_W$Turnout08_U)
frame$Control[8] <- mean(fraga1_CandC_W$Turnout10_U)
frame$Control[9] <- mean(fraga1_CandC_W$Turnout12_U)

frame$PVal <- NA
frame$PVal[3] <- t.test(fraga1_CandT_W$PctFem_U, fraga1_CandC_W$PctFem_U)$p.value
frame$PVal[4] <- t.test(fraga1_CandT_W$Pct20_U, fraga1_CandC_W$Pct20_U)$p.value
frame$PVal[5] <- t.test(fraga1_CandT_W$Pct55_U, fraga1_CandC_W$Pct55_U)$p.value
frame$PVal[6] <- t.test(fraga1_CandT_W$Turnout06_U, fraga1_CandC_W$Turnout06_U)$p.value
frame$PVal[7] <- t.test(fraga1_CandT_W$Turnout08_U, fraga1_CandC_W$Turnout08_U)$p.value
frame$PVal[8] <- t.test(fraga1_CandT_W$Turnout10_U, fraga1_CandC_W$Turnout10_U)$p.value
frame$PVal[9] <- t.test(fraga1_CandT_W$Turnout12_U, fraga1_CandC_W$Turnout12_U)$p.value

frame$TreatedM <- 0
frame$TreatedM[1] <- sum(fraga1_CandT_W[!duplicated(fraga1_CandT_W[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$TreatedM[2] <- nrow(unique(subset(fraga1_CandT_W, select=c(State, PreDist, TreatDist, ControlDist))))
frame$TreatedM[3] <- mean(fraga1_CandT_W$PctFem_M)
frame$TreatedM[4] <- mean(fraga1_CandT_W$Pct20_M)
frame$TreatedM[5] <- mean(fraga1_CandT_W$Pct55_M)
frame$TreatedM[6] <- mean(fraga1_CandT_W$Turnout06_M)
frame$TreatedM[7] <- mean(fraga1_CandT_W$Turnout08_M)
frame$TreatedM[8] <- mean(fraga1_CandT_W$Turnout10_M)
frame$TreatedM[9] <- mean(fraga1_CandT_W$Turnout12_M)

frame$ControlM <- 0
frame$ControlM[1] <- sum(fraga1_CandC_W[!duplicated(fraga1_CandC_W[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$ControlM[2] <- nrow(unique(subset(fraga1_CandC_W, select=c(State, PreDist, TreatDist, ControlDist))))
frame$ControlM[3] <- mean(fraga1_CandC_W$PctFem_M)
frame$ControlM[4] <- mean(fraga1_CandC_W$Pct20_M)
frame$ControlM[5] <- mean(fraga1_CandC_W$Pct55_M)
frame$ControlM[6] <- mean(fraga1_CandC_W$Turnout06_M)
frame$ControlM[7] <- mean(fraga1_CandC_W$Turnout08_M)
frame$ControlM[8] <- mean(fraga1_CandC_W$Turnout10_M)
frame$ControlM[9] <- mean(fraga1_CandC_W$Turnout12_M)

frame$PValM <- NA
frame$PValM[3] <- t.test(fraga1_CandT_W$PctFem_M, fraga1_CandC_W$PctFem_M)$p.value
frame$PValM[4] <- t.test(fraga1_CandT_W$Pct20_M, fraga1_CandC_W$Pct20_M)$p.value
frame$PValM[5] <- t.test(fraga1_CandT_W$Pct55_M, fraga1_CandC_W$Pct55_M)$p.value
frame$PValM[6] <- t.test(fraga1_CandT_W$Turnout06_M, fraga1_CandC_W$Turnout06_M)$p.value
frame$PValM[7] <- t.test(fraga1_CandT_W$Turnout08_M, fraga1_CandC_W$Turnout08_M)$p.value
frame$PValM[8] <- t.test(fraga1_CandT_W$Turnout10_M, fraga1_CandC_W$Turnout10_M)$p.value
frame$PValM[9] <- t.test(fraga1_CandT_W$Turnout12_M, fraga1_CandC_W$Turnout12_M)$p.value

#######
frame # Matches statistics for Whites in Table 2 of Main Text and Table B.2 of Online Appendix
#######

# Stats for Black Registrants
fraga1_CandT_B <- subset(fraga1_CandT, Group == "Black")
fraga1_CandC_B <- subset(fraga1_CandC, Group == "Black")

frame <- as.data.frame(c("N","District Pairs", "Pct Female","Pct Age 20-29","Pct Age 55+","Pct Turnout 06","Pct Turnout 08","Pct Turnout 10","Pct Turnout 12"))
colnames(frame) <- "X"

frame$Treated <- 0
frame$Treated[1] <- sum(fraga1_CandT_B[!duplicated(fraga1_CandT_B[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Treated[2] <- nrow(unique(subset(fraga1_CandT_B, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Treated[3] <- mean(fraga1_CandT_B$PctFem_U)
frame$Treated[4] <- mean(fraga1_CandT_B$Pct20_U)
frame$Treated[5] <- mean(fraga1_CandT_B$Pct55_U)
frame$Treated[6] <- mean(fraga1_CandT_B$Turnout06_U)
frame$Treated[7] <- mean(fraga1_CandT_B$Turnout08_U)
frame$Treated[8] <- mean(fraga1_CandT_B$Turnout10_U)
frame$Treated[9] <- mean(fraga1_CandT_B$Turnout12_U)

frame$Control <- 0
frame$Control[1] <- sum(fraga1_CandC_B[!duplicated(fraga1_CandC_B[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Control[2] <- nrow(unique(subset(fraga1_CandC_B, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Control[3] <- mean(fraga1_CandC_B$PctFem_U)
frame$Control[4] <- mean(fraga1_CandC_B$Pct20_U)
frame$Control[5] <- mean(fraga1_CandC_B$Pct55_U)
frame$Control[6] <- mean(fraga1_CandC_B$Turnout06_U)
frame$Control[7] <- mean(fraga1_CandC_B$Turnout08_U)
frame$Control[8] <- mean(fraga1_CandC_B$Turnout10_U)
frame$Control[9] <- mean(fraga1_CandC_B$Turnout12_U)

frame$PVal <- NA
frame$PVal[3] <- t.test(fraga1_CandT_B$PctFem_U, fraga1_CandC_B$PctFem_U)$p.value
frame$PVal[4] <- t.test(fraga1_CandT_B$Pct20_U, fraga1_CandC_B$Pct20_U)$p.value
frame$PVal[5] <- t.test(fraga1_CandT_B$Pct55_U, fraga1_CandC_B$Pct55_U)$p.value
frame$PVal[6] <- t.test(fraga1_CandT_B$Turnout06_U, fraga1_CandC_B$Turnout06_U)$p.value
frame$PVal[7] <- t.test(fraga1_CandT_B$Turnout08_U, fraga1_CandC_B$Turnout08_U)$p.value
frame$PVal[8] <- t.test(fraga1_CandT_B$Turnout10_U, fraga1_CandC_B$Turnout10_U)$p.value
frame$PVal[9] <- t.test(fraga1_CandT_B$Turnout12_U, fraga1_CandC_B$Turnout12_U)$p.value

frame$TreatedM <- 0
frame$TreatedM[1] <- sum(fraga1_CandT_B[!duplicated(fraga1_CandT_B[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$TreatedM[2] <- nrow(unique(subset(fraga1_CandT_B, select=c(State, PreDist, TreatDist, ControlDist))))
frame$TreatedM[3] <- mean(fraga1_CandT_B$PctFem_M)
frame$TreatedM[4] <- mean(fraga1_CandT_B$Pct20_M)
frame$TreatedM[5] <- mean(fraga1_CandT_B$Pct55_M)
frame$TreatedM[6] <- mean(fraga1_CandT_B$Turnout06_M)
frame$TreatedM[7] <- mean(fraga1_CandT_B$Turnout08_M)
frame$TreatedM[8] <- mean(fraga1_CandT_B$Turnout10_M)
frame$TreatedM[9] <- mean(fraga1_CandT_B$Turnout12_M)

frame$ControlM <- 0
frame$ControlM[1] <- sum(fraga1_CandC_B[!duplicated(fraga1_CandC_B[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$ControlM[2] <- nrow(unique(subset(fraga1_CandC_B, select=c(State, PreDist, TreatDist, ControlDist))))
frame$ControlM[3] <- mean(fraga1_CandC_B$PctFem_M)
frame$ControlM[4] <- mean(fraga1_CandC_B$Pct20_M)
frame$ControlM[5] <- mean(fraga1_CandC_B$Pct55_M)
frame$ControlM[6] <- mean(fraga1_CandC_B$Turnout06_M)
frame$ControlM[7] <- mean(fraga1_CandC_B$Turnout08_M)
frame$ControlM[8] <- mean(fraga1_CandC_B$Turnout10_M)
frame$ControlM[9] <- mean(fraga1_CandC_B$Turnout12_M)

frame$PValM <- NA
frame$PValM[3] <- t.test(fraga1_CandT_B$PctFem_M, fraga1_CandC_B$PctFem_M)$p.value
frame$PValM[4] <- t.test(fraga1_CandT_B$Pct20_M, fraga1_CandC_B$Pct20_M)$p.value
frame$PValM[5] <- t.test(fraga1_CandT_B$Pct55_M, fraga1_CandC_B$Pct55_M)$p.value
frame$PValM[6] <- t.test(fraga1_CandT_B$Turnout06_M, fraga1_CandC_B$Turnout06_M)$p.value
frame$PValM[7] <- t.test(fraga1_CandT_B$Turnout08_M, fraga1_CandC_B$Turnout08_M)$p.value
frame$PValM[8] <- t.test(fraga1_CandT_B$Turnout10_M, fraga1_CandC_B$Turnout10_M)$p.value
frame$PValM[9] <- t.test(fraga1_CandT_B$Turnout12_M, fraga1_CandC_B$Turnout12_M)$p.value

#######
frame # Matches statistics for Blacks in Table 2 of Main Text and Table B.2 of Online Appendix
#######

# Stats for Latino Registrants
fraga1_CandT_L <- subset(fraga1_CandT, Group == "Latino")
fraga1_CandC_L <- subset(fraga1_CandC, Group == "Latino")

frame <- as.data.frame(c("N","District Pairs", "Pct Female","Pct Age 20-29","Pct Age 55+","Pct Turnout 06","Pct Turnout 08","Pct Turnout 10","Pct Turnout 12"))
colnames(frame) <- "X"

frame$Treated <- 0
frame$Treated[1] <- sum(fraga1_CandT_L[!duplicated(fraga1_CandT_L[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Treated[2] <- nrow(unique(subset(fraga1_CandT_L, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Treated[3] <- mean(fraga1_CandT_L$PctFem_U)
frame$Treated[4] <- mean(fraga1_CandT_L$Pct20_U)
frame$Treated[5] <- mean(fraga1_CandT_L$Pct55_U)
frame$Treated[6] <- mean(fraga1_CandT_L$Turnout06_U)
frame$Treated[7] <- mean(fraga1_CandT_L$Turnout08_U)
frame$Treated[8] <- mean(fraga1_CandT_L$Turnout10_U)
frame$Treated[9] <- mean(fraga1_CandT_L$Turnout12_U)

frame$Control <- 0
frame$Control[1] <- sum(fraga1_CandC_L[!duplicated(fraga1_CandC_L[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Control[2] <- nrow(unique(subset(fraga1_CandC_L, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Control[3] <- mean(fraga1_CandC_L$PctFem_U)
frame$Control[4] <- mean(fraga1_CandC_L$Pct20_U)
frame$Control[5] <- mean(fraga1_CandC_L$Pct55_U)
frame$Control[6] <- mean(fraga1_CandC_L$Turnout06_U)
frame$Control[7] <- mean(fraga1_CandC_L$Turnout08_U)
frame$Control[8] <- mean(fraga1_CandC_L$Turnout10_U)
frame$Control[9] <- mean(fraga1_CandC_L$Turnout12_U)

frame$PVal <- NA
frame$PVal[3] <- t.test(fraga1_CandT_L$PctFem_U, fraga1_CandC_L$PctFem_U)$p.value
frame$PVal[4] <- t.test(fraga1_CandT_L$Pct20_U, fraga1_CandC_L$Pct20_U)$p.value
frame$PVal[5] <- t.test(fraga1_CandT_L$Pct55_U, fraga1_CandC_L$Pct55_U)$p.value
frame$PVal[6] <- t.test(fraga1_CandT_L$Turnout06_U, fraga1_CandC_L$Turnout06_U)$p.value
frame$PVal[7] <- t.test(fraga1_CandT_L$Turnout08_U, fraga1_CandC_L$Turnout08_U)$p.value
frame$PVal[8] <- t.test(fraga1_CandT_L$Turnout10_U, fraga1_CandC_L$Turnout10_U)$p.value
frame$PVal[9] <- t.test(fraga1_CandT_L$Turnout12_U, fraga1_CandC_L$Turnout12_U)$p.value

frame$TreatedM <- 0
frame$TreatedM[1] <- sum(fraga1_CandT_L[!duplicated(fraga1_CandT_L[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$TreatedM[2] <- nrow(unique(subset(fraga1_CandT_L, select=c(State, PreDist, TreatDist, ControlDist))))
frame$TreatedM[3] <- mean(fraga1_CandT_L$PctFem_M)
frame$TreatedM[4] <- mean(fraga1_CandT_L$Pct20_M)
frame$TreatedM[5] <- mean(fraga1_CandT_L$Pct55_M)
frame$TreatedM[6] <- mean(fraga1_CandT_L$Turnout06_M)
frame$TreatedM[7] <- mean(fraga1_CandT_L$Turnout08_M)
frame$TreatedM[8] <- mean(fraga1_CandT_L$Turnout10_M)
frame$TreatedM[9] <- mean(fraga1_CandT_L$Turnout12_M)

frame$ControlM <- 0
frame$ControlM[1] <- sum(fraga1_CandC_L[!duplicated(fraga1_CandC_L[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$ControlM[2] <- nrow(unique(subset(fraga1_CandC_L, select=c(State, PreDist, TreatDist, ControlDist))))
frame$ControlM[3] <- mean(fraga1_CandC_L$PctFem_M)
frame$ControlM[4] <- mean(fraga1_CandC_L$Pct20_M)
frame$ControlM[5] <- mean(fraga1_CandC_L$Pct55_M)
frame$ControlM[6] <- mean(fraga1_CandC_L$Turnout06_M)
frame$ControlM[7] <- mean(fraga1_CandC_L$Turnout08_M)
frame$ControlM[8] <- mean(fraga1_CandC_L$Turnout10_M)
frame$ControlM[9] <- mean(fraga1_CandC_L$Turnout12_M)

frame$PValM <- NA
frame$PValM[3] <- t.test(fraga1_CandT_L$PctFem_M, fraga1_CandC_L$PctFem_M)$p.value
frame$PValM[4] <- t.test(fraga1_CandT_L$Pct20_M, fraga1_CandC_L$Pct20_M)$p.value
frame$PValM[5] <- t.test(fraga1_CandT_L$Pct55_M, fraga1_CandC_L$Pct55_M)$p.value
frame$PValM[6] <- t.test(fraga1_CandT_L$Turnout06_M, fraga1_CandC_L$Turnout06_M)$p.value
frame$PValM[7] <- t.test(fraga1_CandT_L$Turnout08_M, fraga1_CandC_L$Turnout08_M)$p.value
frame$PValM[8] <- t.test(fraga1_CandT_L$Turnout10_M, fraga1_CandC_L$Turnout10_M)$p.value
frame$PValM[9] <- t.test(fraga1_CandT_L$Turnout12_M, fraga1_CandC_L$Turnout12_M)$p.value

#######
frame # Matches statistics for Latinos in Table 2 of Main Text and Table B.2 of Online Appendix
#######

# Stats for Asian Registrants
fraga1_CandT_A <- subset(fraga1_CandT, Group == "Asian")
fraga1_CandC_A <- subset(fraga1_CandC, Group == "Asian")

frame <- as.data.frame(c("N","District Pairs", "Pct Female","Pct Age 20-29","Pct Age 55+","Pct Turnout 06","Pct Turnout 08","Pct Turnout 10","Pct Turnout 12"))
colnames(frame) <- "X"

frame$Treated <- 0
frame$Treated[1] <- sum(fraga1_CandT_A[!duplicated(fraga1_CandT_A[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Treated[2] <- nrow(unique(subset(fraga1_CandT_A, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Treated[3] <- mean(fraga1_CandT_A$PctFem_U)
frame$Treated[4] <- mean(fraga1_CandT_A$Pct20_U)
frame$Treated[5] <- mean(fraga1_CandT_A$Pct55_U)
frame$Treated[6] <- mean(fraga1_CandT_A$Turnout06_U)
frame$Treated[7] <- mean(fraga1_CandT_A$Turnout08_U)
frame$Treated[8] <- mean(fraga1_CandT_A$Turnout10_U)
frame$Treated[9] <- mean(fraga1_CandT_A$Turnout12_U)

frame$Control <- 0
frame$Control[1] <- sum(fraga1_CandC_A[!duplicated(fraga1_CandC_A[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Control[2] <- nrow(unique(subset(fraga1_CandC_A, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Control[3] <- mean(fraga1_CandC_A$PctFem_U)
frame$Control[4] <- mean(fraga1_CandC_A$Pct20_U)
frame$Control[5] <- mean(fraga1_CandC_A$Pct55_U)
frame$Control[6] <- mean(fraga1_CandC_A$Turnout06_U)
frame$Control[7] <- mean(fraga1_CandC_A$Turnout08_U)
frame$Control[8] <- mean(fraga1_CandC_A$Turnout10_U)
frame$Control[9] <- mean(fraga1_CandC_A$Turnout12_U)

frame$PVal <- NA
frame$PVal[3] <- t.test(fraga1_CandT_A$PctFem_U, fraga1_CandC_A$PctFem_U)$p.value
frame$PVal[4] <- t.test(fraga1_CandT_A$Pct20_U, fraga1_CandC_A$Pct20_U)$p.value
frame$PVal[5] <- t.test(fraga1_CandT_A$Pct55_U, fraga1_CandC_A$Pct55_U)$p.value
frame$PVal[6] <- t.test(fraga1_CandT_A$Turnout06_U, fraga1_CandC_A$Turnout06_U)$p.value
frame$PVal[7] <- t.test(fraga1_CandT_A$Turnout08_U, fraga1_CandC_A$Turnout08_U)$p.value
frame$PVal[8] <- t.test(fraga1_CandT_A$Turnout10_U, fraga1_CandC_A$Turnout10_U)$p.value
frame$PVal[9] <- t.test(fraga1_CandT_A$Turnout12_U, fraga1_CandC_A$Turnout12_U)$p.value

frame$TreatedM <- 0
frame$TreatedM[1] <- sum(fraga1_CandT_A[!duplicated(fraga1_CandT_A[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$TreatedM[2] <- nrow(unique(subset(fraga1_CandT_A, select=c(State, PreDist, TreatDist, ControlDist))))
frame$TreatedM[3] <- mean(fraga1_CandT_A$PctFem_M)
frame$TreatedM[4] <- mean(fraga1_CandT_A$Pct20_M)
frame$TreatedM[5] <- mean(fraga1_CandT_A$Pct55_M)
frame$TreatedM[6] <- mean(fraga1_CandT_A$Turnout06_M)
frame$TreatedM[7] <- mean(fraga1_CandT_A$Turnout08_M)
frame$TreatedM[8] <- mean(fraga1_CandT_A$Turnout10_M)
frame$TreatedM[9] <- mean(fraga1_CandT_A$Turnout12_M)

frame$ControlM <- 0
frame$ControlM[1] <- sum(fraga1_CandC_A[!duplicated(fraga1_CandC_A[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$ControlM[2] <- nrow(unique(subset(fraga1_CandC_A, select=c(State, PreDist, TreatDist, ControlDist))))
frame$ControlM[3] <- mean(fraga1_CandC_A$PctFem_M)
frame$ControlM[4] <- mean(fraga1_CandC_A$Pct20_M)
frame$ControlM[5] <- mean(fraga1_CandC_A$Pct55_M)
frame$ControlM[6] <- mean(fraga1_CandC_A$Turnout06_M)
frame$ControlM[7] <- mean(fraga1_CandC_A$Turnout08_M)
frame$ControlM[8] <- mean(fraga1_CandC_A$Turnout10_M)
frame$ControlM[9] <- mean(fraga1_CandC_A$Turnout12_M)

frame$PValM <- NA
frame$PValM[3] <- t.test(fraga1_CandT_A$PctFem_M, fraga1_CandC_A$PctFem_M)$p.value
frame$PValM[4] <- t.test(fraga1_CandT_A$Pct20_M, fraga1_CandC_A$Pct20_M)$p.value
frame$PValM[5] <- t.test(fraga1_CandT_A$Pct55_M, fraga1_CandC_A$Pct55_M)$p.value
frame$PValM[6] <- t.test(fraga1_CandT_A$Turnout06_M, fraga1_CandC_A$Turnout06_M)$p.value
frame$PValM[7] <- t.test(fraga1_CandT_A$Turnout08_M, fraga1_CandC_A$Turnout08_M)$p.value
frame$PValM[8] <- t.test(fraga1_CandT_A$Turnout10_M, fraga1_CandC_A$Turnout10_M)$p.value
frame$PValM[9] <- t.test(fraga1_CandT_A$Turnout12_M, fraga1_CandC_A$Turnout12_M)$p.value

#######
frame # Matches statistics for Asians in Table 2 of Main Text and Table B.2 of Online Appendix
#######

###################################
## TABLE 3 (and B.3 of Appendix) ##

# Subset to Majority-Minority Treatment, split into Treatment and Control Districts
fraga1_Maj <- subset(fraga1, Treatment == "Maj")
fraga1_MajT <- subset(fraga1_Maj, PostDist == TreatDist)
fraga1_MajC <- subset(fraga1_Maj, PostDist == ControlDist)

# Stats for White Registrants
fraga1_MajT_W <- subset(fraga1_MajT, Group == "White")
fraga1_MajC_W <- subset(fraga1_MajC, Group == "White")

frame <- as.data.frame(c("N","District Pairs", "Pct Female","Pct Age 20-29","Pct Age 55+","Pct Turnout 06","Pct Turnout 08","Pct Turnout 10","Pct Turnout 12"))
colnames(frame) <- "X"

frame$Treated <- 0
frame$Treated[1] <- sum(fraga1_MajT_W[!duplicated(fraga1_MajT_W[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Treated[2] <- nrow(unique(subset(fraga1_MajT_W, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Treated[3] <- mean(fraga1_MajT_W$PctFem_U)
frame$Treated[4] <- mean(fraga1_MajT_W$Pct20_U)
frame$Treated[5] <- mean(fraga1_MajT_W$Pct55_U)
frame$Treated[6] <- mean(fraga1_MajT_W$Turnout06_U)
frame$Treated[7] <- mean(fraga1_MajT_W$Turnout08_U)
frame$Treated[8] <- mean(fraga1_MajT_W$Turnout10_U)
frame$Treated[9] <- mean(fraga1_MajT_W$Turnout12_U)

frame$Control <- 0
frame$Control[1] <- sum(fraga1_MajC_W[!duplicated(fraga1_MajC_W[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Control[2] <- nrow(unique(subset(fraga1_MajC_W, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Control[3] <- mean(fraga1_MajC_W$PctFem_U)
frame$Control[4] <- mean(fraga1_MajC_W$Pct20_U)
frame$Control[5] <- mean(fraga1_MajC_W$Pct55_U)
frame$Control[6] <- mean(fraga1_MajC_W$Turnout06_U)
frame$Control[7] <- mean(fraga1_MajC_W$Turnout08_U)
frame$Control[8] <- mean(fraga1_MajC_W$Turnout10_U)
frame$Control[9] <- mean(fraga1_MajC_W$Turnout12_U)

frame$PVal <- NA
frame$PVal[3] <- t.test(fraga1_MajT_W$PctFem_U, fraga1_MajC_W$PctFem_U)$p.value
frame$PVal[4] <- t.test(fraga1_MajT_W$Pct20_U, fraga1_MajC_W$Pct20_U)$p.value
frame$PVal[5] <- t.test(fraga1_MajT_W$Pct55_U, fraga1_MajC_W$Pct55_U)$p.value
frame$PVal[6] <- t.test(fraga1_MajT_W$Turnout06_U, fraga1_MajC_W$Turnout06_U)$p.value
frame$PVal[7] <- t.test(fraga1_MajT_W$Turnout08_U, fraga1_MajC_W$Turnout08_U)$p.value
frame$PVal[8] <- t.test(fraga1_MajT_W$Turnout10_U, fraga1_MajC_W$Turnout10_U)$p.value
frame$PVal[9] <- t.test(fraga1_MajT_W$Turnout12_U, fraga1_MajC_W$Turnout12_U)$p.value

frame$TreatedM <- 0
frame$TreatedM[1] <- sum(fraga1_MajT_W[!duplicated(fraga1_MajT_W[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$TreatedM[2] <- nrow(unique(subset(fraga1_MajT_W, select=c(State, PreDist, TreatDist, ControlDist))))
frame$TreatedM[3] <- mean(fraga1_MajT_W$PctFem_M)
frame$TreatedM[4] <- mean(fraga1_MajT_W$Pct20_M)
frame$TreatedM[5] <- mean(fraga1_MajT_W$Pct55_M)
frame$TreatedM[6] <- mean(fraga1_MajT_W$Turnout06_M)
frame$TreatedM[7] <- mean(fraga1_MajT_W$Turnout08_M)
frame$TreatedM[8] <- mean(fraga1_MajT_W$Turnout10_M)
frame$TreatedM[9] <- mean(fraga1_MajT_W$Turnout12_M)

frame$ControlM <- 0
frame$ControlM[1] <- sum(fraga1_MajC_W[!duplicated(fraga1_MajC_W[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$ControlM[2] <- nrow(unique(subset(fraga1_MajC_W, select=c(State, PreDist, TreatDist, ControlDist))))
frame$ControlM[3] <- mean(fraga1_MajC_W$PctFem_M)
frame$ControlM[4] <- mean(fraga1_MajC_W$Pct20_M)
frame$ControlM[5] <- mean(fraga1_MajC_W$Pct55_M)
frame$ControlM[6] <- mean(fraga1_MajC_W$Turnout06_M)
frame$ControlM[7] <- mean(fraga1_MajC_W$Turnout08_M)
frame$ControlM[8] <- mean(fraga1_MajC_W$Turnout10_M)
frame$ControlM[9] <- mean(fraga1_MajC_W$Turnout12_M)

frame$PValM <- NA
frame$PValM[3] <- t.test(fraga1_MajT_W$PctFem_M, fraga1_MajC_W$PctFem_M)$p.value
frame$PValM[4] <- t.test(fraga1_MajT_W$Pct20_M, fraga1_MajC_W$Pct20_M)$p.value
frame$PValM[5] <- t.test(fraga1_MajT_W$Pct55_M, fraga1_MajC_W$Pct55_M)$p.value
frame$PValM[6] <- t.test(fraga1_MajT_W$Turnout06_M, fraga1_MajC_W$Turnout06_M)$p.value
frame$PValM[7] <- t.test(fraga1_MajT_W$Turnout08_M, fraga1_MajC_W$Turnout08_M)$p.value
frame$PValM[8] <- t.test(fraga1_MajT_W$Turnout10_M, fraga1_MajC_W$Turnout10_M)$p.value
frame$PValM[9] <- t.test(fraga1_MajT_W$Turnout12_M, fraga1_MajC_W$Turnout12_M)$p.value

#######
frame # Matches statistics for Whites in Table 3 of Main Text and Table B.3 of Online Appendix
#######

# Stats for Black Registrants
fraga1_MajT_B <- subset(fraga1_MajT, Group == "Black")
fraga1_MajC_B <- subset(fraga1_MajC, Group == "Black")

frame <- as.data.frame(c("N","District Pairs", "Pct Female","Pct Age 20-29","Pct Age 55+","Pct Turnout 06","Pct Turnout 08","Pct Turnout 10","Pct Turnout 12"))
colnames(frame) <- "X"

frame$Treated <- 0
frame$Treated[1] <- sum(fraga1_MajT_B[!duplicated(fraga1_MajT_B[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Treated[2] <- nrow(unique(subset(fraga1_MajT_B, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Treated[3] <- mean(fraga1_MajT_B$PctFem_U)
frame$Treated[4] <- mean(fraga1_MajT_B$Pct20_U)
frame$Treated[5] <- mean(fraga1_MajT_B$Pct55_U)
frame$Treated[6] <- mean(fraga1_MajT_B$Turnout06_U)
frame$Treated[7] <- mean(fraga1_MajT_B$Turnout08_U)
frame$Treated[8] <- mean(fraga1_MajT_B$Turnout10_U)
frame$Treated[9] <- mean(fraga1_MajT_B$Turnout12_U)

frame$Control <- 0
frame$Control[1] <- sum(fraga1_MajC_B[!duplicated(fraga1_MajC_B[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Control[2] <- nrow(unique(subset(fraga1_MajC_B, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Control[3] <- mean(fraga1_MajC_B$PctFem_U)
frame$Control[4] <- mean(fraga1_MajC_B$Pct20_U)
frame$Control[5] <- mean(fraga1_MajC_B$Pct55_U)
frame$Control[6] <- mean(fraga1_MajC_B$Turnout06_U)
frame$Control[7] <- mean(fraga1_MajC_B$Turnout08_U)
frame$Control[8] <- mean(fraga1_MajC_B$Turnout10_U)
frame$Control[9] <- mean(fraga1_MajC_B$Turnout12_U)

frame$PVal <- NA
frame$PVal[3] <- t.test(fraga1_MajT_B$PctFem_U, fraga1_MajC_B$PctFem_U)$p.value
frame$PVal[4] <- t.test(fraga1_MajT_B$Pct20_U, fraga1_MajC_B$Pct20_U)$p.value
frame$PVal[5] <- t.test(fraga1_MajT_B$Pct55_U, fraga1_MajC_B$Pct55_U)$p.value
frame$PVal[6] <- t.test(fraga1_MajT_B$Turnout06_U, fraga1_MajC_B$Turnout06_U)$p.value
frame$PVal[7] <- t.test(fraga1_MajT_B$Turnout08_U, fraga1_MajC_B$Turnout08_U)$p.value
frame$PVal[8] <- t.test(fraga1_MajT_B$Turnout10_U, fraga1_MajC_B$Turnout10_U)$p.value
frame$PVal[9] <- t.test(fraga1_MajT_B$Turnout12_U, fraga1_MajC_B$Turnout12_U)$p.value

frame$TreatedM <- 0
frame$TreatedM[1] <- sum(fraga1_MajT_B[!duplicated(fraga1_MajT_B[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$TreatedM[2] <- nrow(unique(subset(fraga1_MajT_B, select=c(State, PreDist, TreatDist, ControlDist))))
frame$TreatedM[3] <- mean(fraga1_MajT_B$PctFem_M)
frame$TreatedM[4] <- mean(fraga1_MajT_B$Pct20_M)
frame$TreatedM[5] <- mean(fraga1_MajT_B$Pct55_M)
frame$TreatedM[6] <- mean(fraga1_MajT_B$Turnout06_M)
frame$TreatedM[7] <- mean(fraga1_MajT_B$Turnout08_M)
frame$TreatedM[8] <- mean(fraga1_MajT_B$Turnout10_M)
frame$TreatedM[9] <- mean(fraga1_MajT_B$Turnout12_M)

frame$ControlM <- 0
frame$ControlM[1] <- sum(fraga1_MajC_B[!duplicated(fraga1_MajC_B[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$ControlM[2] <- nrow(unique(subset(fraga1_MajC_B, select=c(State, PreDist, TreatDist, ControlDist))))
frame$ControlM[3] <- mean(fraga1_MajC_B$PctFem_M)
frame$ControlM[4] <- mean(fraga1_MajC_B$Pct20_M)
frame$ControlM[5] <- mean(fraga1_MajC_B$Pct55_M)
frame$ControlM[6] <- mean(fraga1_MajC_B$Turnout06_M)
frame$ControlM[7] <- mean(fraga1_MajC_B$Turnout08_M)
frame$ControlM[8] <- mean(fraga1_MajC_B$Turnout10_M)
frame$ControlM[9] <- mean(fraga1_MajC_B$Turnout12_M)

frame$PValM <- NA
frame$PValM[3] <- t.test(fraga1_MajT_B$PctFem_M, fraga1_MajC_B$PctFem_M)$p.value
frame$PValM[4] <- t.test(fraga1_MajT_B$Pct20_M, fraga1_MajC_B$Pct20_M)$p.value
frame$PValM[5] <- t.test(fraga1_MajT_B$Pct55_M, fraga1_MajC_B$Pct55_M)$p.value
frame$PValM[6] <- t.test(fraga1_MajT_B$Turnout06_M, fraga1_MajC_B$Turnout06_M)$p.value
frame$PValM[7] <- t.test(fraga1_MajT_B$Turnout08_M, fraga1_MajC_B$Turnout08_M)$p.value
frame$PValM[8] <- t.test(fraga1_MajT_B$Turnout10_M, fraga1_MajC_B$Turnout10_M)$p.value
frame$PValM[9] <- t.test(fraga1_MajT_B$Turnout12_M, fraga1_MajC_B$Turnout12_M)$p.value

#######
frame # Matches statistics for Blacks in Table 3 of Main Text and Table B.3 of Online Appendix
#######

# Stats for Latino Registrants
fraga1_MajT_L <- subset(fraga1_MajT, Group == "Latino")
fraga1_MajC_L <- subset(fraga1_MajC, Group == "Latino")

frame <- as.data.frame(c("N","District Pairs", "Pct Female","Pct Age 20-29","Pct Age 55+","Pct Turnout 06","Pct Turnout 08","Pct Turnout 10","Pct Turnout 12"))
colnames(frame) <- "X"

frame$Treated <- 0
frame$Treated[1] <- sum(fraga1_MajT_L[!duplicated(fraga1_MajT_L[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Treated[2] <- nrow(unique(subset(fraga1_MajT_L, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Treated[3] <- mean(fraga1_MajT_L$PctFem_U)
frame$Treated[4] <- mean(fraga1_MajT_L$Pct20_U)
frame$Treated[5] <- mean(fraga1_MajT_L$Pct55_U)
frame$Treated[6] <- mean(fraga1_MajT_L$Turnout06_U)
frame$Treated[7] <- mean(fraga1_MajT_L$Turnout08_U)
frame$Treated[8] <- mean(fraga1_MajT_L$Turnout10_U)
frame$Treated[9] <- mean(fraga1_MajT_L$Turnout12_U)

frame$Control <- 0
frame$Control[1] <- sum(fraga1_MajC_L[!duplicated(fraga1_MajC_L[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Control[2] <- nrow(unique(subset(fraga1_MajC_L, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Control[3] <- mean(fraga1_MajC_L$PctFem_U)
frame$Control[4] <- mean(fraga1_MajC_L$Pct20_U)
frame$Control[5] <- mean(fraga1_MajC_L$Pct55_U)
frame$Control[6] <- mean(fraga1_MajC_L$Turnout06_U)
frame$Control[7] <- mean(fraga1_MajC_L$Turnout08_U)
frame$Control[8] <- mean(fraga1_MajC_L$Turnout10_U)
frame$Control[9] <- mean(fraga1_MajC_L$Turnout12_U)

frame$PVal <- NA
frame$PVal[3] <- t.test(fraga1_MajT_L$PctFem_U, fraga1_MajC_L$PctFem_U)$p.value
frame$PVal[4] <- t.test(fraga1_MajT_L$Pct20_U, fraga1_MajC_L$Pct20_U)$p.value
frame$PVal[5] <- t.test(fraga1_MajT_L$Pct55_U, fraga1_MajC_L$Pct55_U)$p.value
frame$PVal[6] <- t.test(fraga1_MajT_L$Turnout06_U, fraga1_MajC_L$Turnout06_U)$p.value
frame$PVal[7] <- t.test(fraga1_MajT_L$Turnout08_U, fraga1_MajC_L$Turnout08_U)$p.value
frame$PVal[8] <- t.test(fraga1_MajT_L$Turnout10_U, fraga1_MajC_L$Turnout10_U)$p.value
frame$PVal[9] <- t.test(fraga1_MajT_L$Turnout12_U, fraga1_MajC_L$Turnout12_U)$p.value

frame$TreatedM <- 0
frame$TreatedM[1] <- sum(fraga1_MajT_L[!duplicated(fraga1_MajT_L[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$TreatedM[2] <- nrow(unique(subset(fraga1_MajT_L, select=c(State, PreDist, TreatDist, ControlDist))))
frame$TreatedM[3] <- mean(fraga1_MajT_L$PctFem_M)
frame$TreatedM[4] <- mean(fraga1_MajT_L$Pct20_M)
frame$TreatedM[5] <- mean(fraga1_MajT_L$Pct55_M)
frame$TreatedM[6] <- mean(fraga1_MajT_L$Turnout06_M)
frame$TreatedM[7] <- mean(fraga1_MajT_L$Turnout08_M)
frame$TreatedM[8] <- mean(fraga1_MajT_L$Turnout10_M)
frame$TreatedM[9] <- mean(fraga1_MajT_L$Turnout12_M)

frame$ControlM <- 0
frame$ControlM[1] <- sum(fraga1_MajC_L[!duplicated(fraga1_MajC_L[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$ControlM[2] <- nrow(unique(subset(fraga1_MajC_L, select=c(State, PreDist, TreatDist, ControlDist))))
frame$ControlM[3] <- mean(fraga1_MajC_L$PctFem_M)
frame$ControlM[4] <- mean(fraga1_MajC_L$Pct20_M)
frame$ControlM[5] <- mean(fraga1_MajC_L$Pct55_M)
frame$ControlM[6] <- mean(fraga1_MajC_L$Turnout06_M)
frame$ControlM[7] <- mean(fraga1_MajC_L$Turnout08_M)
frame$ControlM[8] <- mean(fraga1_MajC_L$Turnout10_M)
frame$ControlM[9] <- mean(fraga1_MajC_L$Turnout12_M)

frame$PValM <- NA
frame$PValM[3] <- t.test(fraga1_MajT_L$PctFem_M, fraga1_MajC_L$PctFem_M)$p.value
frame$PValM[4] <- t.test(fraga1_MajT_L$Pct20_M, fraga1_MajC_L$Pct20_M)$p.value
frame$PValM[5] <- t.test(fraga1_MajT_L$Pct55_M, fraga1_MajC_L$Pct55_M)$p.value
frame$PValM[6] <- t.test(fraga1_MajT_L$Turnout06_M, fraga1_MajC_L$Turnout06_M)$p.value
frame$PValM[7] <- t.test(fraga1_MajT_L$Turnout08_M, fraga1_MajC_L$Turnout08_M)$p.value
frame$PValM[8] <- t.test(fraga1_MajT_L$Turnout10_M, fraga1_MajC_L$Turnout10_M)$p.value
frame$PValM[9] <- t.test(fraga1_MajT_L$Turnout12_M, fraga1_MajC_L$Turnout12_M)$p.value

#######
frame # Matches statistics for Latinos in Table 3 of Main Text and Table B.3 of Online Appendix
#######

# Stats for Asian Registrants
fraga1_MajT_A <- subset(fraga1_MajT, Group == "Asian")
fraga1_MajC_A <- subset(fraga1_MajC, Group == "Asian")

frame <- as.data.frame(c("N","District Pairs", "Pct Female","Pct Age 20-29","Pct Age 55+","Pct Turnout 06","Pct Turnout 08","Pct Turnout 10","Pct Turnout 12"))
colnames(frame) <- "X"

frame$Treated <- 0
frame$Treated[1] <- sum(fraga1_MajT_A[!duplicated(fraga1_MajT_A[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Treated[2] <- nrow(unique(subset(fraga1_MajT_A, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Treated[3] <- mean(fraga1_MajT_A$PctFem_U)
frame$Treated[4] <- mean(fraga1_MajT_A$Pct20_U)
frame$Treated[5] <- mean(fraga1_MajT_A$Pct55_U)
frame$Treated[6] <- mean(fraga1_MajT_A$Turnout06_U)
frame$Treated[7] <- mean(fraga1_MajT_A$Turnout08_U)
frame$Treated[8] <- mean(fraga1_MajT_A$Turnout10_U)
frame$Treated[9] <- mean(fraga1_MajT_A$Turnout12_U)

frame$Control <- 0
frame$Control[1] <- sum(fraga1_MajC_A[!duplicated(fraga1_MajC_A[,c("State","PreDist","PostDist")]),]$Registrants_U)
frame$Control[2] <- nrow(unique(subset(fraga1_MajC_A, select=c(State, PreDist, TreatDist, ControlDist))))
frame$Control[3] <- mean(fraga1_MajC_A$PctFem_U)
frame$Control[4] <- mean(fraga1_MajC_A$Pct20_U)
frame$Control[5] <- mean(fraga1_MajC_A$Pct55_U)
frame$Control[6] <- mean(fraga1_MajC_A$Turnout06_U)
frame$Control[7] <- mean(fraga1_MajC_A$Turnout08_U)
frame$Control[8] <- mean(fraga1_MajC_A$Turnout10_U)
frame$Control[9] <- mean(fraga1_MajC_A$Turnout12_U)

frame$PVal <- NA
frame$PVal[3] <- t.test(fraga1_MajT_A$PctFem_U, fraga1_MajC_A$PctFem_U)$p.value
frame$PVal[4] <- t.test(fraga1_MajT_A$Pct20_U, fraga1_MajC_A$Pct20_U)$p.value
frame$PVal[5] <- t.test(fraga1_MajT_A$Pct55_U, fraga1_MajC_A$Pct55_U)$p.value
frame$PVal[6] <- t.test(fraga1_MajT_A$Turnout06_U, fraga1_MajC_A$Turnout06_U)$p.value
frame$PVal[7] <- t.test(fraga1_MajT_A$Turnout08_U, fraga1_MajC_A$Turnout08_U)$p.value
frame$PVal[8] <- t.test(fraga1_MajT_A$Turnout10_U, fraga1_MajC_A$Turnout10_U)$p.value
frame$PVal[9] <- t.test(fraga1_MajT_A$Turnout12_U, fraga1_MajC_A$Turnout12_U)$p.value

frame$TreatedM <- 0
frame$TreatedM[1] <- sum(fraga1_MajT_A[!duplicated(fraga1_MajT_A[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$TreatedM[2] <- nrow(unique(subset(fraga1_MajT_A, select=c(State, PreDist, TreatDist, ControlDist))))
frame$TreatedM[3] <- mean(fraga1_MajT_A$PctFem_M)
frame$TreatedM[4] <- mean(fraga1_MajT_A$Pct20_M)
frame$TreatedM[5] <- mean(fraga1_MajT_A$Pct55_M)
frame$TreatedM[6] <- mean(fraga1_MajT_A$Turnout06_M)
frame$TreatedM[7] <- mean(fraga1_MajT_A$Turnout08_M)
frame$TreatedM[8] <- mean(fraga1_MajT_A$Turnout10_M)
frame$TreatedM[9] <- mean(fraga1_MajT_A$Turnout12_M)

frame$ControlM <- 0
frame$ControlM[1] <- sum(fraga1_MajC_A[!duplicated(fraga1_MajC_A[,c("State","PreDist","PostDist")]),]$Registrants_M)
frame$ControlM[2] <- nrow(unique(subset(fraga1_MajC_A, select=c(State, PreDist, TreatDist, ControlDist))))
frame$ControlM[3] <- mean(fraga1_MajC_A$PctFem_M)
frame$ControlM[4] <- mean(fraga1_MajC_A$Pct20_M)
frame$ControlM[5] <- mean(fraga1_MajC_A$Pct55_M)
frame$ControlM[6] <- mean(fraga1_MajC_A$Turnout06_M)
frame$ControlM[7] <- mean(fraga1_MajC_A$Turnout08_M)
frame$ControlM[8] <- mean(fraga1_MajC_A$Turnout10_M)
frame$ControlM[9] <- mean(fraga1_MajC_A$Turnout12_M)

frame$PValM <- NA
frame$PValM[3] <- t.test(fraga1_MajT_A$PctFem_M, fraga1_MajC_A$PctFem_M)$p.value
frame$PValM[4] <- t.test(fraga1_MajT_A$Pct20_M, fraga1_MajC_A$Pct20_M)$p.value
frame$PValM[5] <- t.test(fraga1_MajT_A$Pct55_M, fraga1_MajC_A$Pct55_M)$p.value
frame$PValM[6] <- t.test(fraga1_MajT_A$Turnout06_M, fraga1_MajC_A$Turnout06_M)$p.value
frame$PValM[7] <- t.test(fraga1_MajT_A$Turnout08_M, fraga1_MajC_A$Turnout08_M)$p.value
frame$PValM[8] <- t.test(fraga1_MajT_A$Turnout10_M, fraga1_MajC_A$Turnout10_M)$p.value
frame$PValM[9] <- t.test(fraga1_MajT_A$Turnout12_M, fraga1_MajC_A$Turnout12_M)$p.value

#######
frame # Matches statistics for Asians in Table 3 of Main Text and Table B.3 of Online Appendix
#######